package com.fingard.dsp.bank.reqrespobj.transaction;

import com.fingard.dsp.bank.reqrespobj.ReqRespHeader;
import com.fingard.dsp.bank.reqrespobj.RetAtsBase;
import com.fingard.dsp.bank.reqrespobj.transaction.detail.RetAtsTransactionReplenishDetail;
import com.fingard.xml.XmlTextReader;
import com.fingard.xml.XmlTextWriter;

import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

public class RetAtsTransactionReplenish extends RetAtsBase {

    //客户号
    public String cusid;
    //业务种类
    public String bustyp;
    //税票号码
    public String taxno;
    //征收机关名称
    public String taxofficename;
    //税种个数
    public String taxcnt;
    //税（费）种名称
    public String taxname1;
    //所属日期
    public String taxdate1;
    //实缴金额
    public String taxamount1;

    private XmlTextReader xmlReader;

    public RetAtsTransactionReplenish(ReqRespHeader p_header) throws Exception{
        retHeader = p_header;
        retXmlWriter = new XmlTextWriter();//用于输出返回ATS的XML报文
    }

    public void writeRetDetail(RetAtsTransactionReplenishDetail p_retDetail, List<RetAtsTransactionTaxModel> list) throws Exception {

        retXmlWriter.writeStartElement("DetailRecord");
        retXmlWriter.writeElementString("Cusid", p_retDetail.cusid);
        retXmlWriter.writeElementString("Receiptno", p_retDetail.receiptno);
        retXmlWriter.writeElementString("Bustyp", p_retDetail.bustyp);
        retXmlWriter.writeElementString("Taxcnt", p_retDetail.taxcnt);
        retXmlWriter.writeElementString("Taxno", p_retDetail.taxno);
        retXmlWriter.writeElementString("Taxofficename", p_retDetail.taxofficename);
        retXmlWriter.writeElementString("Receiptjrnlno", p_retDetail.receiptjrnlno);
        if(Integer.valueOf(p_retDetail.taxcnt)==list.size() && list.size()>0){
            for(RetAtsTransactionTaxModel dto : list) {
                retXmlWriter.writeStartElement("TaxRecord");
                retXmlWriter.writeElementString("Taxdate",dto.getTaxdate());
                retXmlWriter.writeElementString("Taxname",dto.getTaxname());
                retXmlWriter.writeElementString("Taxamount",dto.getTaxamount());
                retXmlWriter.writeEndElement();
            }
        }
        retXmlWriter.writeEndElement();
    }
}
